#ifndef __H_GAME_H__
#define __H_GAME_H__

#include <deque>
#include <vector>
#include <map>
#include <set>
#include "ICC_Timer_Handler.h"
#include "RedisClient.h"
#include "GameBase.h"
#include "DbPart.h"
#include "CClient.h"
#include "def.h"
#include "LogicData.h"

#include <rabbitmq-c/amqp.h>
#include <rabbitmq-c/tcp_socket.h>


class CHost;

class CGameServer : public BYTimerOject
{
public:
	CGameServer();
	virtual ~CGameServer();

public:
	virtual bool InitGame();
	virtual int OnBYTimeOut(int Timerid);
	int ProcessPacket(SocketHandler * pHandler, NETInputPacket* inputPkg);

public:
	CHost* m_pHost;

private:
	// MQ
	bool initmq(void);							// 初始化MQ
	void releasemq(void);						// 释放MQ
	bool ReadCommonConf(const char* strxml);	// 读取配置

	int procEvent(SocketHandler* pHandler, NETInputPacket* inputPkg);
	int PushPbToMQ(const std::string& exchange, const std::string& routingKey, const google::protobuf::Message& pbMsg);

private:
	// MQ 链接参数
	std::string m_mqIp;
	
	unsigned short m_mqPort;
	std::string m_mqVhost;
	std::string m_mqUsername;
	std::string m_mqPassword;

	amqp_connection_state_t m_mqConnection;// MQ 链接
	int m_mqChannel;// MQ 通道	

	// 交换机类型
	static const char* m_mqExchangeType;// 一对一 精准路由模式

	// 交换机
	static const char* m_mqExchange_NonBusiness;	// 非业务事件: 进入房间
	static const char* m_mqExchange_Business;		// 业务事件: 下注 取消下注 结算 牌局明细

	// 路由键
	static const char* m_mqRoutingKey_NonBusiness;
	static const char* m_mqRoutingKey_Business;

	// 消息队列
	static const char* m_mqQueue_NonBusiness;
	static const char* m_mqQueue_Business;
};

#endif
